package com.czl.module_service.adapter.asset

import com.chad.library.adapter.base.BaseQuickAdapter
import com.chad.library.adapter.base.viewholder.BaseDataBindingHolder
import com.czl.base.data.bean.tengyun.SortBean
import com.czl.module_service.R
import com.czl.module_service.databinding.ItemPurchaseSortListBinding
import com.czl.module_service.fragment.assetUse.PurchaseSortListFragment

class PurchaseSortListAdapter(private val fragment: PurchaseSortListFragment) :
    BaseQuickAdapter<SortBean, BaseDataBindingHolder<ItemPurchaseSortListBinding>>(
        R.layout.item_purchase_sort_list
    ) {

    override fun convert(
        holder: BaseDataBindingHolder<ItemPurchaseSortListBinding>,
        item: SortBean,
    ) {
        item.price = String.format("%.2f",item.price.toString().toDouble())
        val totalPrice = item.price.toString().toDouble() * item.sortNum!!
        item.totalPrice = String.format("%.2f",totalPrice)
        holder.dataBinding?.run {
            data = item
            adapter = this@PurchaseSortListAdapter
            executePendingBindings()
        }
    }
}